'use strict';

const Controller = require('./base');

class GlobalController extends Controller {
  async setSiteOptions() {
    const { ctx, service } = this;
    const query = ctx.request.body;
    const arr = [];
    for (const k in query) {
      const data = {};
      data.key = query[k].key;
      data.value = query[k].value;
      arr.push(data);
    }
    const result = await service.setting.create(arr);
    this.success(result);
  }

  async getSiteOptions() {
    const { service } = this;
    const result = await service.setting.find();
    this.success(result);
  }
}

module.exports = GlobalController;
